r/learnjavascript • • Jan 22 '26

Help with Objects

4 Upvotes

I don't get the purpose of value()

let dictionary = Object.create(null, {
  toString: { // define toString property
    value() { // the value is a function
      return Object.keys(this).join();
    }
  }
});

Why we can't make it work like this?

toString: {
      return Object.keys(this).join();
}

r/learnjavascript • • Jan 22 '26

How to check if archive format password protected / encrypted ?

1 Upvotes

Hello everyone, i have a task - i need to check if archive formats (eg. arj, zip, 7z, rar, tar, tgz) are password protected - encrypted. I have a React TS app.
My app allows users to work with files - upload, download, and edit them. And when someone upload encrypted archive i need to somehow save this info (maybe "isPasswordProtected" field or smth) and when other, different user click on this archive - i need to show in interface that archive is password protected (info bubble or smth)

BUT the main questions are:

  1. how do i check if archive is encrypted without unzipping it or just partly unzip it?
  2. Does provided archive formats has some kind of headers or smth like that? For example - if i want to check it on server - what exactly i need to check for?
  3. How to check it on client-side(frontend) ?

If u can, please, share some info or links or how file/archive should look like bc i think im a little lost right now


r/learnjavascript • • Jan 22 '26

Is it possible to check if a function with a specific parameter signature(?) exists?

0 Upvotes

Just curious - I know I can check if a specific function exists with

if (typeof myFunction !== "undefined") ...

Let's say myFunction could either be function myFunction() or function myFunction(parameter1), depending on which version of a library is loaded. typeof myFunction returns "function", is there a way to know if it's myFunction() or myFunction(parameter1)?

(Not sure if "parameter signature" is the right terminology)


r/learnjavascript • • Jan 21 '26

Is there a way to have payload validation with json-server?

1 Upvotes

I'm trying to create an api testing project for a portfolio, and json-server is great for showing when things go well, but since I'm in QA so I want to test things not going well like unauthorized access and missing required fields/not matching the schema. Is that possible with json-server or will I need to learn how to make an actual API to do this?