Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
@lucaspar that's new to me but would you reuse the word import like
import gulp from 'gulp',
import sass from 'gulp-sass' ? -
@lucaspar I want to know the difference we use A and C, like why C over A or B? Or if A or B, why?
I use A because I hate to re declare variable -
@nothappy you're not redeclaring anything, gulp and sass are two different constants
-
I might be the only one who does this but I put all my initializers in top, grouped up.
e.g. if I wanted to import mongoose to connect to a mongo instance, and then import a scheme and make a model out of it, and then initialize an Express web server
/* DB */
const mongoose = require("mongoose")
mongoose.connect(/* do de connects */)
const schema = require("./schema.js")
const User = mongoose.model('User', schema.user)
/* Server */
const express = require("express")
const app = express()
app.use(express.json())
app.use(express.static('./static'))
/* *********** */
I find it somewhat more organized and it makes it easier to edit initializations and work with long scripts that have lots of pieces that are too small to be their own file but too big to be intermittently stitched while maintaining readability.
Of course I also rely on my format code shortcut to put in semicolons and properly format things so maybe I'm just a heathen through and through 😅
A)
const gulp = require("gulp"),
sass = require("gulp-sass");
OR
B)
const gulp = require("gulp"),
const sass = require("gulp-sass");
I use A
question