javascript - ||和 javascript 中的 onmessage

标签 javascript appjs

我正在阅读一个开源项目,它有一个 js file像这样

var pipe = function(source, listeners){
    source.onmessage = function onmessage(msg){
           //.. do something ..
    };

    return {
      //.. something ...
    };
  }(nativeWindow || appjs, {});

(nativeWindow || appjs ) 是什么意思,它们都是对象?

这是否意味着他们都调用了这个函数?

或者它正在合并这两个对象?

这个 .onmessage 是像 alert()window 这样的标准东西吗?我所说的标准是指在这个 .onmessage 函数的幕后发生了什么,或者它就像简单的函数一样?

谢谢

最佳答案

如果 nativeWindow 的计算结果为 false(例如,如果它未定义),则 appjs 作为源传入;否则 nativeWindow 作为源传入。然后将作为源传入的任何对象的属性 onmessage 设置为 onmessage 函数

关于javascript - ||和 javascript 中的 onmessage,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18717070/

相关文章:

javascript - 将回调添加到 JavaScript 函数中(AngularJS 上的应用)

javascript - 初学融合表查询...两列位置和st_distance

javascript - 滚动条的图像未在 Amcharts 中正确显示

javascript - 委托(delegate)单击事件仅在第二次单击前进后才起作用

sqlite - NodeJS + AppJS + Sqlite3

javascript - 尽管设备像素比固定图像大小

javascript - 使用 Node.js Express 更新加载的值

node.js - fs.writeFile() 不返回回调

node.js - 在 Mountain Lion 上安装 32 位 Node

macos - 我无法在 OS X 上打包 appjs 应用程序