-1

Is there a single word that can describe JavaScript functions, variables, and objects? I was thinking "entities", but that word is usually used to describe the mapping between objects and a database. And I'm trying to be more descriptive than calling them just "things". Also, "concepts" or "ideas" seem a bit too abstract... Is there another word I could use that is more concrete?

For example: "In JavaScript, 'scope' is the set of ____(word)____ you have access to."

The example was taken from this article in w3schools, and I was wondering if there is another term that succinctly covers function, variables, and objects.

  • 1
    In other languages, sometimes they are called identifiers (emphasizing the ability to refer to them by name) or symbols (emphasizing the role they play in linking - a step that isn't relevant at all to JavaScript.) – rwong Jul 2 '16 at 16:35
  • If I got it right all Javascript ____(word)____ are objects, but anyway. – user6245072 Jul 2 '16 at 16:50
  • 1
    @rwong: An "identifier" is the name of the thing, not the named thing. – Lightness Races in Orbit Jul 2 '16 at 17:20
  • In the context, a scope is the set of identifier bindings that you have access to. – JacquesB Jul 2 '16 at 17:22
  • 1
    Variables are pretty different things from functions and objects. This would be easier to answer if you said what, specifically, you're trying to describe that apparently covers all three categories. – user7043 Jul 2 '16 at 17:46
1

There is no common term (and you don't need one) since they are different categories of things. The quote uses imprecise language:

In JavaScript, scope is the set of variables, objects, and functions you have access to.

Technically this is wrong, since it confuses variables and values, which are distinct concepts. A scope is a set of variables. A variable is a named reference to a value. Objects, functions and primitives are values. So there is a level of indirection between variable and value which mean you cannot lump them together.

  • You make interesting points. I'm wondering then if it is valid to say that these are JS "constructs"?? I'm not sure. If functions are a kind of object, and an object is a kind of value, and variables contain values, then is there a word that can describe both the value and the "slot"? If you were to buy shoes at a store you would describe it as just "buying shoes" despite that the item comes with a shoe box ("slot"). But, is it correct to say that variables, objects, and functions are all types of values? – Dash Jul 2 '16 at 18:07
  • @Dash: A variable is not a type of value, so no. Language constructs or language element are broad terms which would encompass both variables and values and many other things. – JacquesB Jul 2 '16 at 18:11
  • Okay, but at least we are getting closer to a possible term. IMHO, Language construct and language element is better than calling them "things" or "concepts" – Dash Jul 2 '16 at 18:28
  • @Dash: My point is you don't need a common term for variables and values, since you would never lump them together in a meaningful sentence. – JacquesB Jul 3 '16 at 10:04
  • Okay, lets step back a bit. I can understand that a JavaScript object is not something that the scope has access to directly unless it is assigned to a variable so that the scope can reference the object by an identifier. And I can understand that functions are values. But, why would it not be valid to say that the scope is the set of functions and variables you have access to? I can see an anonymous function have problems since there is no identifier associated with it, but a named function is definitely something a scope might have access to. – Dash Jul 3 '16 at 15:03
0

"Entities" is a good catch-all term, although it is not widely used because there is not often a reason to refer to such a broad group of things.

Indeed, your proposed quotation is wrong: scope limits visibility of names of things, not of named things. So you could say "names", or use the technical term "identifiers".

  • I didn't downvote. I think your answer and the other comments are very helpful. I was actually debating "entities", but after reading another discussion on Stack Overflow and another discussion here I thought there might be another term that is more suitable. But, then again, I'm not sure if functions and variables in JavaScript are actually objects... – Dash Jul 2 '16 at 17:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.