用node,2024年最新大厂前端核心面试题出炉

In the root directly, go open up webpack.config.js and add the

publicPath ‘/’ as per below:

path: 'public',
filename: 'bundle.js',

When you run npm start it checks if the value of our NODE_ENV

environment variable is production. If yes, it runs `npm run

start:prod, if not, it runs npm run start:dev`.

Now we’re ready to create a production server with Express and add a

new file at root dir. Here’s a first attempt:

require(‘path’)

var app = express()

// serve our static stuff like index.css

app.use(express.static(__dirname))

// send all requests to index.html so browserHistory in React Router

works app.get(‘*’, function (req, res) {

res.sendFile(path.join(__dirname, ‘index.html’)) })

var PORT = process.env.PORT || 8080 app.listen(PORT, function() {

console.log(‘Production Express server running at localhost:’ + PORT)

Now run:

For Windows users:

Congratulations! You now have a production server for this app. After

clicking around, try navigating to

http://localhost:8080/package.json.

Whoops. Let’s fix that. We’re going to shuffle around a couple files

and update some paths scattered across the app.

  1. make a public directory.
  1. Move index.html and index.css into it.

Now let’s update server.js to point to the right directory for

static assets:

app.use(express.static(path.join(__dirname, ‘public’)))

// … app.get(‘*’, function (req, res) { // and drop ‘public’ in

the middle of here res.sendFile(path.join(__dirname, ‘public’,

We also need to tell webpack to build to this new directory:

And finally (!) add it to the --content-base argument to `npm run

start:dev` script:

If we had the time in this tutorial, we could use the

WebpackDevServer API in a JavaScript file instead of the CLI in an

npm script and then turn this path into config shared across all of

these files. But, we’re already on a tangent, so that will have to

wait for another time.

Okay, now that we aren’t serving up the root of our project as public

files, let’s add some code minification to Webpack and gzipping to

express.

// make sure to import this var webpack = require(‘webpack’)

module.exports = { // …

// add this handful of plugins that optimize the build // when

we’re in production plugins: process.env.NODE_ENV === ‘production’ ?

[

new webpack.optimize.DedupePlugin(),
new webpack.optimize.OccurrenceOrderPlugin(),
new webpack.optimize.UglifyJsPlugin()   ] : [],

And compression in express:

Now go start your server in production mode:

You’ll see some UglifyJS logging and then in the browser, you can see

the assets are being served with gzip compression.

自我介绍一下,小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。

深知大多数前端工程师,想要提升技能,往往是自己摸索成长或者是报班学习,但对于培训机构动则几千的学费,着实压力不小。自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!

因此收集整理了一份《2024年Web前端开发全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。
img
img
img
img
img
img

既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上前端开发知识点,真正体系化!

由于文件比较大,这里只是将部分目录大纲截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且后续会持续更新

如果你觉得这些内容对你有帮助,可以添加V获取:vip1024c (备注前端)
img

JavaScript

  • js的基本类型有哪些?引用类型有哪些?null和undefined的区别。

  • 如何判断一个变量是Array类型?如何判断一个变量是Number类型?(都不止一种)

  • Object是引用类型嘛?引用类型和基本类型有什么区别?哪个是存在堆哪一个是存在栈上面的?

  • JS常见的dom操作api

  • 解释一下事件冒泡和事件捕获

  • 事件委托(手写例子),事件冒泡和捕获,如何阻止冒泡?如何组织默认事件?

  • 对闭包的理解?什么时候构成闭包?闭包的实现方法?闭包的优缺点?

  • this有哪些使用场景?跟C,Java中的this有什么区别?如何改变this的值?

  • call,apply,bind

  • 显示原型和隐式原型,手绘原型链,原型链是什么?为什么要有原型链

  • 创建对象的多种方式

  • 实现继承的多种方式和优缺点

  • new 一个对象具体做了什么

  • 手写Ajax,XMLHttpRequest

  • 变量提升

  • 举例说明一个匿名函数的典型用例

  • 指出JS的宿主对象和原生对象的区别,为什么扩展JS内置对象不是好的做法?有哪些内置对象和内置函数?

  • attribute和property的区别

  • document load和document DOMContentLoaded两个事件的区别

  • JS代码调试

一个人可以走的很快,但一群人才能走的更远。不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎扫码加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!
img

ument DOMContentLoaded两个事件的区别

  • JS代码调试

一个人可以走的很快,但一群人才能走的更远。不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎扫码加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!
[外链图片转存中…(img-m0Rw4EVz-1712785905497)]

  • 14
    点赞
  • 25
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值