我一直在这个问题上停留太久了。这是我要回答的问题:
//write a forEach loop that loops through this example array and prints out the type of each element
var arr = [{name:'Pedrito'}, ['Banana'],false,34,'hello',null,undefined]
答案 0 :(得分:1)
var arr = [{name:'Pedrito'}, ['Banana'],false,34,'hello',null,undefined]
arr.forEach(e => console.log(typeof e));
答案 1 :(得分:0)
您可以使用以下方法:
arr.forEach( item => console.log(typeof item) );
答案 2 :(得分:0)
FYI typeof
均为小写:
arr.forEach(element => console.log(typeof element))
答案 3 :(得分:0)
您可以使用以下解决方案:
// Serve static content for the app from the "public" directory in the application directory.
// if production env, use build folder for static files
if (process.env.NODE_ENV === "production") {
app.use(express.static("client/build"));
}
// for local env, use /client/public folder
else {
app.use(express.static(path.join(__dirname, '/client/public')));
}
// server the client index.html file for all requests
app.get("*", function(req, res) {
res.sendFile(path.join(__dirname, "./client/public/index.html"));
});
日志:
var arr = [{name:'Pedrito'}, ['Banana'],false,34,'hello',null,undefined]
arr.forEach(function(element){
console.log(typeof element)
})