最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

四十分鐘JavaScript快速入門 | 無廢話且清晰流暢 | 手敲鍵盤 ...

2023-09-05 23:08 作者:Ealsen  | 我要投稿

// The test is note.

// Date 2023.09.05?

// Night?





// 你好,世界!

console.log("hello world!");


// var 全局變量

// let 局部變量


let age=30;

console.log(age);


//const aae;XXXXXXXd

// const 定義的變量此后不能修改

const media = 40;


//media = 50;

console.log(media);



// 數(shù)據(jù)的基本類型

let ade;

ade = 'a';

console.log(ade);




const me = "wdasdw";

console.log(me);




const name1 = "woder";

console.log(name1);

const raer = undefined;

console.log(raer);

const iscook = false;

console.log(iscook);


const isfile = true;

console.log(isfile);


const num1 = 1;

console.log(num1);


const num2 = 2.2;

console.log(num2);


console.log(typeof isfile);


console.log(typeof num1);



const unnum=null;

console.log(unnum);

console.log(typeof unnum);

console.log(typeof raer);

// confirm(typeof num1);?

// confirm 彈出



// 控制臺“+”輸出

console.log("hello"+' '+"world");



const usname ="Make";

const age1 = 30;


// 控制臺輸出模塊化

console.log(`My name is ${usname} and I am ${age1}`);


// 定義字符串

const s1 = "Hello world";

// 長度

console.log(s1.length);

// 大寫

console.log(s1.toUpperCase());

// 小寫

console.log(s1.toLowerCase());

console.log(s1.substring(0,5));

console.log(s1.split(""));

console.log(s1.split(", "));



// 數(shù)組

const num123=new Array(1,2,3,4,5,6,7,8,9);

console.log(num123);


// 數(shù)組的簡單定義

const number = ["asd0",'dwad','dwadasufg',true,null,10];

console.log(number);



console.log(number[0]);


// 在末尾加上

number.push("NewAdd");


console.log(number);


// 在頭部加上

number.unshift("Fornt");


console.log(number);



// 刪除末尾的

// number.pop();


console.log(number);



// 判斷數(shù)據(jù)是否為數(shù)組

console.log(Array.isArray('hello'));

console.log(Array.isArray(number));


// 得到索引

console.log(number.indexOf("asd0"));



// 數(shù)組的更多操作可看js文檔





// 對象

const person ={

??firstName:"Make",

??lastName:"Dan",

??age:30,

??hobbies:["Music","Movies","Sports"],

??address:{

????street:"50 main St",

????city:"WuHan",

????state:"MA",

??},

};


console.log(person);


console.log(person.firstName);

console.log(person.address.street);


// 抽象剝離

const {firstName, lastName ,address:{city},} = person;


console.log(firstName);


console.log(city);


// 添加屬性

person.email = "Make@mail.com";


console.log(person);




// 對象數(shù)組


let result = [

??{

????id:1,

????subject: 'math',

????score: 10,

????isGood:false,

??},

??{

????id:2,

????subject: 'chinese',

????score: 20,

????isGood:false,

??},

??{

????id:3,

????subject: 'english',

????score: 30,

????isGood:true,

??}

];


// 下標

console.log(result[1].subject);


// 對象數(shù)組轉(zhuǎn)化為JSON

const resultJSON = JSON.stringify(result);


console.log(resultJSON);



// if


const xx=4;


// === 考慮數(shù)據(jù)類型 == 不考慮

if (xx === 10){

??console.log("xx is 10");

} else{

??console.log("xx is not 10")

}



if (xx == 10){

??console.log("xx is 10");

}


if (xx > 10){

console.log("xx > 10");

}




const yy =11;



if (yy > 5 || yy > 10){

console.log("xx > 5 or yy > 10");

}


if (yy > 100 && yy > 10){

??console.log("xx > 100 and yy > 10");

??}





// 三目運算符

const xxx=10;

const color = xxx > 10 ? 'red' : 'blue';

console.log(color);



// switch

switch(color){

??case 'red':

????console.log("color is red");

????break;

??case 'blue':

????console.log("color is blue");

????break;

??default:

????console.log("color is Not red or blue");

}



// for and while

for (let i =0;i<10;i++){

??console.log(i);

}


console.log("-----");


let i = 0;

while (i < 10) {

??console.log(i);

??i+=2;

}




let result1s = [

??{

????id:1,

????subject: 'math',

????score: 10,

????isGood:false,

??},

??{

????id:2,

????subject: 'chinese',

????score: 20,

????isGood:false,

??},

??{

????id:3,

????subject: 'english',

????score: 30,

????isGood:true,

??}

];


// 循環(huán)打印result1s中的每一項 類似于python的for x in xs():

for (let result1 of result1s){

??console.log(result1);

}

四十分鐘JavaScript快速入門 | 無廢話且清晰流暢 | 手敲鍵盤 ...的評論 (共 條)

分享到微博請遵守國家法律
同心县| 洪泽县| 右玉县| 秦皇岛市| 金寨县| 墨江| 富宁县| 康定县| 收藏| 辽阳市| 新丰县| 富锦市| 田东县| 红原县| 庆阳市| 石景山区| 宁安市| 崇仁县| 郁南县| 萨嘎县| 南开区| 永康市| 炎陵县| 台中县| 墨玉县| 锡林浩特市| 江陵县| 巩义市| 丹江口市| 菏泽市| 林州市| 涞水县| 新营市| 离岛区| 扎囊县| 积石山| 凤庆县| 通榆县| 奇台县| 蕉岭县| 赣州市|