JavaScript 最让我惊讶的部分是它周围总是有新事物发生。 而且,无论您对它了解多少,您都将始终了解有关它的新事物。
这些问题我收集了很长时间。 在大多数问题中,我真的不知道输出会是什么,直到我自己尝试了它们。
所以在这里我将它们记录下来,以便其他人可以利用它来学习新概念:
输出:
21
{name: “Lydia”} // age won’t be included. Because property defined with defineProperty are non enumerable by default.
输出:
false // delete operator only deletes a key in object
true // when we don't use any declaration before any variable, it will be treated as a global variable, and will be added as deletable entity in window object.undefined
输出:
[ { name: "Noren Red"} ] Initially I thought it will log [ null ] because we have initialised person with nullBut in reality, we are only setting new reference to person variable. Previous reference will be used in members arrayIn Short, { name: "Noren Red"} lives in some memory space whose address is X201and this is how referencing is workinglet person = X201
const members = [ X201 ]
person = null
输出:
Silver Surfer Because when we return a property, the value of the property is equal to the returned value, not the value set in the constructor function.
输出:
With the padStart method, we can add padding to the beginning of a string.
The value passed to this method is the total length of the string together with the padding. The string "Silver Surfer" has a length of 13. name.padStart(14) inserts 1 space at the start of the string, because 13 + 1 is 13. If the argument passed to the padStart method is smaller than the length of the array, no padding will be added.
输出:
777If we pass string and number combination to parseInt, what parseInt does is, it check at which position wrong datatype is getting started, if value before the wrong datatype is a valid number, it will return the valid number.
输出:
1 2 and undefined 3 and undefined 4
If we don't pass initial value, then by default x will be first value of array, and y will be second value of array.
输出:
one - ["", " is ", " years old"]
two - Thor
three - 1000one - ["hey there, are you amazed"]
two - undefined
three - undefinedIf we use tagged template literals, the value of the first argument is always an array of the string values.The remaining arguments get the values of the passed expressions!
输出:
1
undefined
2
输出:
function // Classes in JS are functions under the hood
关注七爪网,获取更多APP/小程序/网站源码资源!
页面更新:2024-03-13
本站资料均由网友自行发布提供,仅用于学习交流。如有版权问题,请与我联系,QQ:4156828
© CopyRight 2008-2024 All Rights Reserved. Powered By bs178.com 闽ICP备11008920号-3
闽公网安备35020302034844号