We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
` public main(): void let test: boolean = this.test() ; console.log("test " + test + " param " + this.m_testNum + " param2 " + this.m_testNum2 + " dadafdfaf " + (this.m_testNum = false)); if (this.m_testNum = false) { console.log("fucking"); } console.log("~~~~"); }
private test(): boolean { return this.m_testNum = this.m_testNum2 = false ; } private test1(): boolean { return true ; }`
return this.m_testNum = this.m_testNum2 = false ; 主要是这句话,在新同学代码review时候,看到有这么用的,奇怪为什么这么用。
return this.m_testNum = this.m_testNum2 = false ;
测试后,我认为,等号操作符,应该在typeScript和c/c++中意思是一样的,多个等号,按从右到左的顺序进行,然后将最右边等号的右值付给左值,然后左值再作为右边第二个的右值,复制给左值。直到最左边,赋值完成,将变量赋值给 return 的值。
if (this.m_testNum = false) 这种也是赋值语句执行完后,将变量返回到判断语句当中
if (this.m_testNum = false)
关于操作符优先级,和操作符结合性的解释: 看 https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Operators/Operator_Precedence (地址拷贝到浏览器)
The text was updated successfully, but these errors were encountered:
No branches or pull requests
测试代码如下
` public main(): void
let test: boolean = this.test() ;
console.log("test " + test + " param " + this.m_testNum + " param2 " + this.m_testNum2 + " dadafdfaf " + (this.m_testNum = false));
if (this.m_testNum = false) {
console.log("fucking");
}
console.log("~~~~");
}
return this.m_testNum = this.m_testNum2 = false ;
主要是这句话,在新同学代码review时候,看到有这么用的,奇怪为什么这么用。
测试后,我认为,等号操作符,应该在typeScript和c/c++中意思是一样的,多个等号,按从右到左的顺序进行,然后将最右边等号的右值付给左值,然后左值再作为右边第二个的右值,复制给左值。直到最左边,赋值完成,将变量赋值给 return 的值。
if (this.m_testNum = false)
这种也是赋值语句执行完后,将变量返回到判断语句当中关于操作符优先级,和操作符结合性的解释:
看
https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Operators/Operator_Precedence (地址拷贝到浏览器)
The text was updated successfully, but these errors were encountered: