水木社区手机版
首页
|版面-Web开发(WebDev)|
新版wap站已上线
返回
1/1
|
转到
主题:再说一下js坑爹的事
楼主
|
hgoldfish
|
2014-10-08 23:38:36
|
只看此ID
(!!prepend ? targetImageList.prepend : targetImageList.append)(o);
和
if(!!prepend) {
targetImageList.prepend(o);
} else {
targetImageList.append(o);
}
等价吗?答案是,不一样。
--
FROM 27.159.58.*
1楼
|
zxdong262
|
2014-10-09 12:34:58
|
只看此ID
crash ?
【 在 hgoldfish 的大作中提到: 】
: (!!prepend ? targetImageList.prepend : targetImageList.append)(o);
: 和
: if(!!prepend) {
: ...................
--
FROM 117.136.40.*
2楼
|
iteddy1314
|
2014-10-09 19:20:15
|
只看此ID
你检查下 你的prepend的值
【 在 hgoldfish 的大作中提到: 】
: (!!prepend ? targetImageList.prepend : targetImageList.append)(o);
: 和
: if(!!prepend) {
: ...................
--
修改:iteddy1314 FROM 123.114.52.*
FROM 123.114.52.*
3楼
|
hgoldfish
|
2014-10-09 19:28:17
|
只看此ID
你理解错了。这个问题是由于js的 this 飘忽不定引起的。
【 在 iteddy1314 (小胖) 的大作中提到: 】
: 你检查下 你的prepend的值
--
FROM 27.159.58.*
4楼
|
iteddy1314
|
2014-10-09 19:30:50
|
只看此ID
那你应该调用 apply
场景描述得不清晰啊
【 在 hgoldfish 的大作中提到: 】
: 你理解错了。这个问题是由于js的 this 飘忽不定引起的。
:
--
FROM 123.114.52.*
5楼
|
hgoldfish
|
2014-10-09 19:31:38
|
只看此ID
我知道啊。只是这件事有点反直觉了。
【 在 iteddy1314 (小胖) 的大作中提到: 】
: 那你应该调用 apply
: 场景描述得不清晰啊
--
FROM 27.159.58.*
6楼
|
XeCycle
|
2014-10-09 19:56:38
|
只看此ID
【 在 hgoldfish (老鱼) 的大作中提到: 】
: (!!prepend ? targetImageList.prepend : targetImageList.append)(o);
targetImageList[!!prepend ? "prepend" : "append"](o)
这样能用吗……
: 和
: if(!!prepend) {
: targetImageList.prepend(o);
: } else {
: targetImageList.append(o);
: }
: 等价吗?答案是,不一样。
--
FROM 180.173.63.*
7楼
|
withinsea
|
2014-10-10 11:49:52
|
只看此ID
对嘛
明显这个才是正确写法……
要用 this 怎么可能不带对象
【 在 XeCycle (据说是小 X) 的大作中提到: 】
: targetImageList[!!prepend ? "prepend" : "append"](o)
: 这样能用吗……
--
FROM 114.243.47.52
1/1
|
转到
选择讨论区
首页
|
分区
|
热推
BYR-Team
©
2010.
KBS Dev-Team
©
2011
登录完整版