Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between {active: "yes"} and {"active": "yes"}?

I've used FireBug to test the two cases and they seem pretty similar by result:

>>> var x = {"active": "yes"}
>>> x.active
"yes"
>>> var x = {active: "yes"}
>>> x.active
"yes"

But I'm pretty sure there is some difference between these two, maybe even performance related difference. Bottom line - I'd like to know if there is a difference between {active: "yes"} and {"active": "yes"}.

like image 342
Eran Betzalel Avatar asked Oct 22 '10 16:10

Eran Betzalel


People also ask

What does net user administrator active yes do?

Net User username /active:yes|no -- e.g. Net User Martin /active:yes -- Activates the account so that it can be used. Setting it to no deactivates the account.

What is a WDAGUtilityAccount?

WDAGUtilityAccount is a built-in user account. It's part of Windows Defender Application Guard (WDAG), which has been part of Windows 10 since version 1709. Usually, Application Guard is disabled by default. You can find it by opening the Command Prompt and typing the net user command.

How do I activate administrator Command Prompt?

In the Administrator: Command Prompt window, type net user and then press the Enter key. NOTE: You will see both the Administrator and Guest accounts listed. To activate the Administrator account, type the command net user administrator /active:yes and then press the Enter key.

How do I enable the administrator account in Windows 10?

Quick guide: Enable administrator account in Windows 10Type “cmd” and press [Ctrl] + [Shift] + [Enter]. Type “net user administrator /active:yes”. The administrator account is now activated.


1 Answers

Both are valid. However there are certain keywords you cant use like delete so in order to avoid that you wrap them in quotes so they are not treated literally by the ECMAScript parser and instead are explicitly specified as strings.

Additionally, the JSON spec requires that keys have quotes around them:

A string begins and ends with
quotation marks

So {key:'value'} is not valid JSON but is valid JS, while {"key":"value"} is valid JS and JSON.

Examples of keywords and invalid/ambiguous keys:

>>> ({delete:1})
SyntaxError: Unexpected token delete
>>> ({'delete':1})
Object

Another example:

>>> ({first-name:'john'})
SyntaxError: Unexpected token -
>>> ({'first-name':'john'})
Object
>>> ({'first-name':'john'})['first-name']
"john"
like image 188
meder omuraliev Avatar answered Nov 14 '22 00:11

meder omuraliev