What is 'typeof define === 'function' && define['amd']' used for?

This code checks for the presence of require.js, a JavaScript dependency management library.

If 'define' is not undefined and it is a function and 'amd' (asynchronous module definition) is also defined then the code assumes that require.js is in play.

If this is so then it defines 'factory' and passes jQuery to it as a dependency. Otherwise it sets up the dependencies that the code needs by attaching them to the root object.

As for what 'factory' is: it is not defined by the Javascript framework, it will be a function in the same file most likely. It will take the parameter jQuery.

What is 'typeof define === 'function' && define['amd']' used for?的更多相关文章

  1. Spark笔记之使用UDF(User Define Function)

    一.UDF介绍 UDF(User Define Function),即用户自定义函数,Spark的官方文档中没有对UDF做过多介绍,猜想可能是认为比较简单吧. 几乎所有sql数据库的实现都为用户提供了 ...

  2. 微信小程序 - cb回调(typeof cb == "function" && cb(obj);)

    typeof cb == "function" && cb(obj) 但凡用了Promise,这种方式就可以抛弃了. Page({ data: {}, onLoad ...

  3. Js Pattern - Self Define Function

    This pattern is useful when your function has some initial preparatory work to do andit needs to do ...

  4. hive 添加UDF(user define function) hive的insert语句

    add JAR /home/hadoop/study/study2/utf.jar; package my.bigdata.udf; import org.apache.hadoop.hive.ql. ...

  5. python define function

    >>> def square(x): ... 'calculates the square of the number x.' ... return x*x ... >> ...

  6. js模块定义——支持CMD&AMD&直接加载

    /* animate */ //直接加载 (function() { var animate = {} //balabala window.animate = animate; })(); //AMD ...

  7. 认识AMD、CMD、UMD、CommonJS

    0.导言 JavaScript的生态系统一直在稳步增长,当各种组件混合使用时,就可能会发现不是所有的组件都能“和平共处”,为了解决这些问题,各种模块规范就出来了. 1.AMD(Asynchromous ...

  8. 解决sea.js引用jQuery提示$ is not a function的问题

    在使用sea.js的如下写法引用jQuery文件时, //main.jsdefine(function(require,exports,module){ var $ = require('jquery ...

  9. angularjs + fis +modJS 对于支持amd规范的组建处理(PhotoSwipe 支持,百度webUpload支持)

    这不是很好的处理方式,但是能够解决问题,希望有大神推荐更好的方式. 前端模块使用angularjs + fis +modJS 开发前端应用有两个月了.总结了以下的优点: fis 自动构建,自动发布,功 ...

随机推荐

  1. redis为什么使用单线程 ,还那么快,单线程是怎么实现的

    单线程使用队列 为什么使用单线程 https://baijiahao.baidu.com/s?id=1628498089535886382&wfr=spider&for=pc http ...

  2. 生成二维码功能(js前端)

    生成二维码需要引入qrcode.js和jquery.min.js <!DOCTYPE html> <head> <title>二维码</title> & ...

  3. html元素标签时间格式化

    <fmt:formatDate value="${user.loginTime}" pattern="yyyy-MM-dd HH:mm:ss"/>

  4. 更新 | 2019年9月计算机二级office模拟题库

    随着2019年上半年计算机二级考试的完美落幕,紧接着的便是9月份的考试了. 到目前为止,下半年9月份计算机二级考试报名开通时间在6月前后,现在也基本结束. 2019年9月(56次)全国计算机等级考试( ...

  5. ArrayList实现原理分析

    ArrayList使用的存储的数据结构 ArrayList的初始化 ArrayList是如何动态增长 ArrayList如何实现元素的移除 ArrayList小结 ArrayList是我们经常使用的一 ...

  6. Linux安装FastDFS~Nginx~

    确保Linux联网,我这里使用的是CentOS7操作,联网教程 https://www.cnblogs.com/taopanfeng/p/10978752.html 先把指定的四个文件放入指定目录 安 ...

  7. 2019-11-29-Roslyn-使用-Directory.Build.props-文件定义编译

    title author date CreateTime categories Roslyn 使用 Directory.Build.props 文件定义编译 lindexi 2019-11-29 08 ...

  8. [转]实际项目中如何使用Git做分支管理 (A successful Git branching model)

    来自 https://nvie.com/posts/a-successful-git-branching-model/ In this post I present the development m ...

  9. Linux系统,无法收到组播消息的问题

    解决办法: 做以下3个修改 1. /etc/sysctl.conf 文件中的 net.ipv4.conf.all.rp_filter 设置成0 2. sysctl -w net.ipv4.conf.a ...

  10. Instr()函数用法

    返回 Variant (Long),指定一字符串在另一字符串中最先出现的位置. 语法 InStr([start, ]string1, string2[, compare]) InStr 函数的语法具有 ...