Skip to content

Instantly share code, notes, and snippets.

@hillbilly300
Created November 4, 2019 11:11
Show Gist options
  • Save hillbilly300/35d67e239e1d6212c8ecf78af22d61d1 to your computer and use it in GitHub Desktop.
Save hillbilly300/35d67e239e1d6212c8ecf78af22d61d1 to your computer and use it in GitHub Desktop.
JS Bin // source https://jsbin.com/puqudin
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
//arrays are objects[subtype of objects]
const user = []
// adding properties with dot notation vs
// brakcets syntax
//short hand way
/*when using dot notation
it does
1.Implicitly coercing value after(.) to string
2.name has to be a valid variable name
3.you canot just have like(user.0 or user.34r)
4.doing action `3` will return a syntax error.
5.if you want to have no `4` , then you
will have to use bracket syntax
*/
user.name = "Waqar Hussain"
//comprehensive way
/*
inside brakcets it can be any valid expression
like number,string,functions(which return
array, or string
)
*/
user[0] = "Waqar Hussain"
user["0"] = "Waqar Hussain"
user[(function(){return 2;})()] =
"Waqar Hussain dsf"
console.log(user)
</script>
<script id="jsbin-source-javascript" type="text/javascript">//arrays are objects[subtype of objects]
const user = []
// adding properties with dot notation vs
// brakcets syntax
//short hand way
/*when using dot notation
it does
1.Implicitly coercing value after(.) to string
2.name has to be a valid variable name
3.you canot just have like(user.0 or user.34r)
4.doing action `3` will return a syntax error.
5.if you want to have no `4` , then you
will have to use bracket syntax
*/
user.name = "Waqar Hussain"
//comprehensive way
/*
inside brakcets it can be any valid expression
like number,string,functions(which return
array, or string
)
*/
user[0] = "Waqar Hussain"
user["0"] = "Waqar Hussain"
user[(function(){return 2;})()] =
"Waqar Hussain dsf"
console.log(user)
</script></body>
</html>
//arrays are objects[subtype of objects]
const user = []
// adding properties with dot notation vs
// brakcets syntax
//short hand way
/*when using dot notation
it does
1.Implicitly coercing value after(.) to string
2.name has to be a valid variable name
3.you canot just have like(user.0 or user.34r)
4.doing action `3` will return a syntax error.
5.if you want to have no `4` , then you
will have to use bracket syntax
*/
user.name = "Waqar Hussain"
//comprehensive way
/*
inside brakcets it can be any valid expression
like number,string,functions(which return
array, or string
)
*/
user[0] = "Waqar Hussain"
user["0"] = "Waqar Hussain"
user[(function(){return 2;})()] =
"Waqar Hussain dsf"
console.log(user)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment