GithubHelp home page GithubHelp logo

notes's Introduction

notes学习笔记

关于Object


对象(Object)是引用类型,在使用过程中会遇到浅拷贝和深拷贝的问题。

let a = { name: 'FE' }
let b = a
b.name = 'EF'
console.log(a.name) // EF

四则运算符


只有当加法运算时,其中一方是字符串类型,就会把另一个也转为字符串类型。其 他运算只要其中一方是数字,那么另一方就转为数字。并且加法运算会触发三种类型转 换:将值转换为原始值,转换为数字,转换为字符串。

 1 + '1' // '11'
 2 * '2' // 4
 [1, 2] + [2, 1] // '1,22,1'
 // [1, 2].toString() -> '1,2'
 // [2, 1].toString() -> '2,1'
 // '1,2' + '2,1' = '1,22,1'

对于加号需要注意这个表达式 'a' + + 'b'

 'a' + + 'b' // -> "aNaN"
 // 因为 + 'b' -> NaN
 // 你也许在一些代码中看到过 + '1' -> 1

每个函数都有 prototype 属性,除了 Function.prototype.bind(),该属性指向 原型。 每个对象都有 __proto__ 属性,指向了创建该对象的构造函数的原型。其实这个 属性指向了 [[prototype]],但是[[prototype]]是内部属性,我们并不能访问到, 所以使用_proto_来访问。 对象可以通过 __proto__ 来寻找不属于该对象的属性,__proto__ 将对象连接起 来组成了原型链。

notes's People

Contributors

chenqj1118 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.