gpt4 book ai didi

javascript - 链函数的基本查询

转载 作者:行者123 更新时间:2023-11-30 15:52:57 24 4
gpt4 key购买 nike

非常基本的问题,但在这种情况下......

const myVariable = GenericObject.myMethod().brand.toUpperCase()

.brand 指的是什么...即这种“链式功能”实际上是如何组合在一起的?

您可以假设 myMethod 返回一个空对象。

谢谢

最佳答案

可能是这样的

function GenericObject() { }

GenericObject.myMethod = function () {
return {
brand: 'string'
};
}

console.log(GenericObject.myMethod().brand.toUpperCase());

或者

var GenericObject = {
myMethod: function () {
return {
brand: 'string'
};
}
};

console.log(GenericObject.myMethod().brand.toUpperCase());

关于javascript - 链函数的基本查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39026729/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com