这个JS代码片做了什么?`"发展"!=='生产'

Die*_*zar 7 javascript boolean

这是react.js文件的全部内容:

if ("development" !== 'production') {
  var typeofSpec = typeof spec;
  var isMixinValid = typeofSpec === 'object' && spec !== null;

  "development" !== 'production' ? warning(isMixinValid, '%s: You\'re attempting to include a mixin that is either null ' + 'or not an object. Check the mixins included by the component, ' + 'as well as any mixins they include themselves. ' + 'Expected object but got %s.', Constructor.displayName || 'ReactClass', spec === null ? null : typeofSpec) : void 0;
}
Run Code Online (Sandbox Code Playgroud)

什么时候会是假的?它以什么方式有用?它是自动生成的吗?

Cli*_*int 1

目的"development" !== 'production'是启用开发模式。这样做的原因是为了在缩小过程中从生产版本中删除该块。

当为生产而构建时,"production" !== "production"永远不可能true,因此该块会被压缩器删除。