Created
November 4, 2019 13:43
-
-
Save hillbilly300/137ede412f48ebe4f9e23b0175461f66 to your computer and use it in GitHub Desktop.
JS Bin // source https://jsbin.com/puqudin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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(typeof Object.keys(user)[0]) | |
console.log(user.length) | |
console.log(user) | |
//create object using bracket and dot notation | |
let acard = ['red'] | |
acard['acard'] = 2; | |
console.log(acard) | |
let card = { | |
name:"weapons" | |
}; | |
card["color"] = "red"; | |
card.age = 2; | |
console.log(card); | |
</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(typeof Object.keys(user)[0]) | |
console.log(user.length) | |
console.log(user) | |
//create object using bracket and dot notation | |
let acard = ['red'] | |
acard['acard'] = 2; | |
console.log(acard) | |
let card = { | |
name:"weapons" | |
}; | |
card["color"] = "red"; | |
card.age = 2; | |
console.log(card); | |
</script></body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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(typeof Object.keys(user)[0]) | |
console.log(user.length) | |
console.log(user) | |
//create object using bracket and dot notation | |
let acard = ['red'] | |
acard['acard'] = 2; | |
console.log(acard) | |
let card = { | |
name:"weapons" | |
}; | |
card["color"] = "red"; | |
card.age = 2; | |
console.log(card); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment