JS-42-Node.js01-Node.js介绍

一、浏览器大战

众所周知,在Netscape设计出JavaScript后的短短几个月,JavaScript事实上已经是前端开发的唯一标准。

后来,微软通过IE击败了Netscape后一统桌面,结果几年时间,浏览器毫无进步。(2001年推出的古老的IE 6到今天仍然有人在使用!)

没有竞争就没有发展。微软认为IE6浏览器已经非常完善,几乎没有可改进之处,然后解散了IE6开发团队!而Google却认为支持现代Web应用的新一代浏览器才刚刚起步,尤其是浏览器负责运行JavaScript的引擎性能还可提升10倍。

先是Mozilla借助已壮烈牺牲的Netscape遗产在2002年推出了Firefox浏览器,紧接着Apple于2003年在开源的KHTML浏览器的基础上推出了WebKit内核的Safari浏览器,不过仅限于Mac平台。

随后,Google也开始创建自家的浏览器。他们也看中了WebKit内核,于是基于WebKit内核推出了Chrome浏览器

Chrome浏览器是跨Windows和Mac平台的,并且,Google认为要运行现代Web应用,浏览器必须有一个性能非常强劲的JavaScript引擎,于是Google自己开发了一个高性能JavaScript引擎,名字叫V8,以BSD许可证开源。

现代浏览器大战让微软的IE浏览器远远地落后了,因为他们解散了最有经验、战斗力最强的浏览器团队!回过头再追赶却发现,支持HTML5的WebKit已经成为手机端的标准了,IE浏览器从此与主流移动端设备绝缘。

二、浏览器大战和Node有何关系?

话说有个叫Ryan Dahl的歪果仁,他的工作是用C/C++写高性能Web服务。对于高性能,异步IO、事件驱动是基本原则,但是用C/C++写就太痛苦了。于是这位仁兄开始设想用高级语言开发Web服务。最终,Ryan瞄向了JavaScript。

因为JavaScript是单线程执行,根本不能进行同步IO操作,所以,JavaScript的这一“缺陷”导致了它只能使用异步IO

选定了开发语言,还要有运行时引擎。这位仁兄曾考虑过自己写一个,不过明智地放弃了,因为V8就是开源的JavaScript引擎。让Google投资去优化V8,咱只负责改造一下拿来用,还不用付钱,这个买卖很划算。

于是在2009年,Ryan正式推出了基于JavaScript语言和V8引擎的开源Web服务器项目,命名为Node.js。虽然名字很土,但是,Node第一次把JavaScript带入到后端服务器开发,加上世界上已经有无数的JavaScript开发人员,所以Node一下子就火了起来。

三、Node.js简介

Node.js是一个基于Chrome V8引擎的JavaScript运行时环境

所以,JS能在前端浏览器中运行,是因为浏览器中有JS的运行环境

若是想让JS做后端开发,则需要借助Node.js。即,Node.js为JS提供了后端的运行环境

所以,一段JS代码,可以在前端的浏览器中运行,也能在后端的Node.js中运行。

正如node官网中的介绍所示:

 

DOM(文档对象模型)、BOM(浏览器对象模型)

Node.js主要用于服务器端编程,处理网络请求、文件操作、数据库交互等任务,而不是直接操作HTML元素。因此,在Node.js中,你通常不会直接获取或操作HTML元素。

四、Node.js可以做什么?

五、Node.js的学习路径

1、JS基础语法(√)

2、Node.js内置API模块;

3、第三方API模块;

  • 14
    点赞
  • 20
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
ERROR Failed to compile with 48 errors 上午10:53:54 These dependencies were not found: * core-js/modules/es.array.push.js in ./node_modules/.store/@[email protected]/node_modules/@babel/runtime/helpers/esm/objectSpread2.js, ./node_modules/.store/[email protected]/node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/.store/[email protected]/node_modules/babel-loader/lib!./node_modules/.store/[email protected]/node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/.store/[email protected]/node_modules/vue-loader/lib??vue-loader-options!./src/components/HeaderSearch/index.vue?vue&type=script&lang=js& and 29 others * core-js/modules/es.error.cause.js in ./node_modules/.store/@[email protected]/node_modules/@babel/runtime/helpers/esm/regeneratorRuntime.js, ./node_modules/.store/[email protected]/node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/.store/[email protected]/node_modules/babel-loader/lib!./node_modules/.store/[email protected]/node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/.store/[email protected]/node_modules/vue-loader/lib??vue-loader-options!./src/layout/components/Navbar.vue?vue&type=script&lang=js& and 5 others * core-js/modules/es.object.proto.js in ./node_modules/.store/@[email protected]/node_modules/@babel/runtime/helpers/esm/regeneratorRuntime.js * core-js/modules/es.regexp.dot-all.js in ./node_modules/.store/[email protected]/node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/.store/[email protected]/node_modules/babel-loader/lib!./node_modules/.store/[email protected]/node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/.store/[email protected]/node_modules/vue-loader/lib??vue-loader-options!./src/components/ThemePicker/index.vue?vue&type=script&lang=js&, ./node_modules/.store/[email protected]/node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/.store/[email protected]/node_modules/babel-loader/lib!./node_modules/.store/[email protected]/node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/.store/[email protected]/node_modules/vue-loader/lib??vue-loader-options!./src/layout/components/Navbar.vue?vue&type=script&lang=js& and 2 others * core-js/modules/web.url-search-params.delete.js in ./src/utils/request.js * core-js/modules/web.url-search-params.has.js in ./src/utils/request.js * core-js/modules/web.url-search-params.size.js in ./src/utils/request.js * qs in ./src/utils/request.js * svg-baker-runtime/browser-symbol in ./src/icons/svg/user.svg To install them, you can run: npm install --save core-js/modules/es.array.push.js core-js/modules/es.error.cause.js core-js/modules/es.object.proto.js core-js/modules/es.regexp.dot-all.js core-js/modules/web.url-search-params.delete.js core-js/modules/web.url-search-params.has.js core-js/modules/web.url-search-params.size.js qs svg-baker-runtime/browser-symbol怎么解决如何安装
07-21

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值