Case Analysis of JavaScript data Type usage
This article mainly explains "JavaScript data type use example analysis". The explanation content in this article is simple and clear, easy to learn and understand. Please follow the idea of Xiaobian and go deep into it slowly to study and learn "JavaScript data type use example analysis" together.
(1) Boolean boolean
Boolean (logical) can have only two values: true or false
var x=true;
var y=false;
(2) null and undefined
null means no object, no value here
undefined means missing value, should have value but not defined
var x = null;
var y = undefined
(3)symbol
Symbol function can accept a string as a parameter, providing a description for the newly created Symbol, used to display it on the console or as a string, easy to distinguish
let name = Symbol();
let name2 = Symbol("bb");
console.log(name); // Symbol()
console.log(typeof name); // "symbol"
console.log(name,name2); //Symbol() Symbol(bb)
console.log( name === name2); // false
(4) Object
Objects are separated by braces. Inside the brackets, the properties of the object are defined in key-value pairs (name : value). Properties separated by commas
//Spaces and breaks don't matter. Declarations can span multiple lines
var obj = {
"name":"zhang san",
"age":18
}
(The key name can also be used without quotation marks)
Reading attributes in objects:
name = obj.name
//or
name = obj['name']
Thank you for reading, the above is the content of "JavaScript data type use example analysis", after the study of this article, I believe that everyone has a deeper understanding of JavaScript data type use example analysis, the specific use of the situation also needs to be verified by practice. Here is, Xiaobian will push more articles related to knowledge points for everyone, welcome to pay attention!