每日一練 JS30天挑戰 JS變數的賦值和引用

2021-10-25 05:41:52 字數 2367 閱讀 2907

lang

="en"

>

>

charset

="utf-8"

>

>

js reference vs copytitle

>

head

>

>

>

let name =

"arvin"

let name2 = name

console.

log(name,name2)

//arvin arvin

name =

'蘋果'

console.

log(name,name2)

//蘋果 arvin

let number =

2let number2 = number

console.

log(number,number2)

//2 2

number =

4 console.

log(number,number2)

//4 2

let bool1 =

true

let bool2 = bool1

console.

log(bool1,bool2)

//true true

bool1 =

false

console.

log(bool1,bool2)

//false true

const players =

['wes'

,'sarah'

,'ryan'

]const team = players

team[3]

='修改了'

console.

log(players,team)

//相同 同一塊堆記憶體

console.

log(players===team)

//true

const team2 = players.

slice()

;//es6展開操作符

const team3 =

[...players]

console.

log(team2)

team2[4]

='我又修改了'

team3[4]

='我也修改了'

console.

log(players,team,team2,team3)

//team2、team3指向了乙個新的堆記憶體

const person =

const dev = person

dev.name =

"小明"

console.

log(person,dev)

//小明 22 小明 22

const dev2 = object.

assign

(,person,

)const dev3 =

//展開操作符

dev3.name =

'小亮'

console.

log(person, dev2, dev3)

//小明 22 小王 22 小亮 22

const author =

}const au2 = object.

assign

(,author)

//淺層次複製

const au3 =

json

.parse

(json

.stringify

(author)

)//深層次複製

console.

log(au2===author)

//false

au2.name =

'王小明'

au2.social.wechat =

'lala - alice --check'

console.

log(author , au2)

=== au2.social

console.

log(au2.social === author.social)

//true

console.

log(au3.social === author.social)

//false

const arr =[1

,2,3

,4]function

fn(arr3)

fn(arr)

script

>

body

>

html

>

每日一練 30天JS挑戰 實時搜尋列表

lang en charset utf 8 type ahead title rel stylesheet href style.css head class search form type text class search placeholder city or state class sug...

每日一練4

員工表emp 員工編號eid,姓名ename,工作職位title,僱傭日期hiretime,工資salary,獎金bonus,部門depart 部門表dept 部門編號did,名稱dname,部門領導leader 員工資料 1001,張三 銷售 1999 12 1 3000.0,1100.0,102...

每日一練25

請描述 mysql 從安裝到配置的全部詳細過程 確保一台新電腦可以順利使用 mysql mysql安裝嚮導啟動,按 next 繼續 選擇安裝型別,有 typical 預設 complete 完全 custom 使用者自定義 三個選項,我們選擇 custom 有更多的選項,也方便熟悉安裝過程 選擇配置...