fix: converted single to triple backticks11 (#36238)
This commit is contained in:
@@ -12,8 +12,9 @@ localeTitle: تجميد الكائن
|
||||
|
||||
### بناء الجملة
|
||||
|
||||
`Object.freeze(obj)
|
||||
`
|
||||
```javascript
|
||||
Object.freeze(obj)
|
||||
```
|
||||
|
||||
### المعلمات
|
||||
|
||||
@@ -31,35 +32,36 @@ localeTitle: تجميد الكائن
|
||||
|
||||
### مثال
|
||||
|
||||
`// Create your object
|
||||
let person = {
|
||||
name: 'Johnny',
|
||||
age: 23,
|
||||
guild: 'Army of Darkness',
|
||||
hobbies: ['music', 'gaming', 'rock climbing']
|
||||
}
|
||||
|
||||
// Modify your object
|
||||
person.name = 'John'
|
||||
person.age = 24
|
||||
person.hobbies.splice(1,1)
|
||||
delete person.guild
|
||||
|
||||
// Verify your object has been modified
|
||||
console.log(person) // { name: 'John', age: 24, hobbies: ['music', 'rock climbing']
|
||||
|
||||
// Freeze your object
|
||||
Object.freeze(person)
|
||||
|
||||
// Verify that your object can no longer be modified
|
||||
person.name = 'Johnny' // fails silently
|
||||
person.age = 23 // fails silently
|
||||
console.log(person) // { name: 'John', age: 24, hobbies: ['music', 'rock climbing']
|
||||
|
||||
// The freeze is "shallow" and nested objects (including arrays) can still be modified
|
||||
person.hobbies.push('basketball')
|
||||
consol.log(person.hobbies) // ['music', 'rock climbing', 'basketball']
|
||||
`
|
||||
```javascript
|
||||
// Create your object
|
||||
let person = {
|
||||
name: 'Johnny',
|
||||
age: 23,
|
||||
guild: 'Army of Darkness',
|
||||
hobbies: ['music', 'gaming', 'rock climbing']
|
||||
}
|
||||
|
||||
// Modify your object
|
||||
person.name = 'John'
|
||||
person.age = 24
|
||||
person.hobbies.splice(1,1)
|
||||
delete person.guild
|
||||
|
||||
// Verify your object has been modified
|
||||
console.log(person) // { name: 'John', age: 24, hobbies: ['music', 'rock climbing']
|
||||
|
||||
// Freeze your object
|
||||
Object.freeze(person)
|
||||
|
||||
// Verify that your object can no longer be modified
|
||||
person.name = 'Johnny' // fails silently
|
||||
person.age = 23 // fails silently
|
||||
console.log(person) // { name: 'John', age: 24, hobbies: ['music', 'rock climbing']
|
||||
|
||||
// The freeze is "shallow" and nested objects (including arrays) can still be modified
|
||||
person.hobbies.push('basketball')
|
||||
consol.log(person.hobbies) // ['music', 'rock climbing', 'basketball']
|
||||
```
|
||||
|
||||
#### معلومات اكثر:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user