'createCloseButton' was used before it was defined
324 table.appendChild(head);
325 var body = createFeatureTableBody(typeString, setString);
326 table.appendChild(body);
327 var closeButton = createCloseButton();328 closeButton.style.position = "absolute";
329 closeButton.style.right = "0px";
330 closeButton.style.top = "0px";
'onMouseUp' was used before it was defined
359
360 if (state !== STATE.NONE) {
361 document.addEventListener("mousemove", onMouseMove, false);
362 document.addEventListener("mouseup", onMouseUp, false);363 scope.dispatchEvent(startEvent);
364 }
365 }
'onMouseMove' was used before it was defined
358 }
359
360 if (state !== STATE.NONE) {
361 document.addEventListener("mousemove", onMouseMove, false);362 document.addEventListener("mouseup", onMouseUp, false);
363 scope.dispatchEvent(startEvent);
364 }
'getAutoRotationAngle' was used before it was defined
251 phi = Math.atan2(Math.sqrt(offset.x * offset.x + offset.z * offset.z), offset.y);
252
253 if (this.autoRotate && state === STATE.NONE) {
254 this.rotateLeft(getAutoRotationAngle());255 }
256
257 theta += thetaDelta;
'getZoomScale' was used before it was defined
220
221 this.dollyOut = function(dollyScale) {
222 if (dollyScale === undefined) {
223 dollyScale = getZoomScale();224 }
225
226 if (scope.object instanceof THREE.PerspectiveCamera) {
'getZoomScale' was used before it was defined
204
205 this.dollyIn = function(dollyScale) {
206 if (dollyScale === undefined) {
207 dollyScale = getZoomScale();208 }
209
210 if (scope.object instanceof THREE.PerspectiveCamera) {
'getAutoRotationAngle' was used before it was defined
147
148 this.rotateUp = function(angle) {
149 if (angle === undefined) {
150 angle = getAutoRotationAngle();151 }
152
153 phiDelta -= angle;
'getAutoRotationAngle' was used before it was defined
139
140 this.rotateLeft = function(angle) {
141 if (angle === undefined) {
142 angle = getAutoRotationAngle();143 }
144
145 thetaDelta -= angle;
'TwoPointRoundedBox' was used before it was defined
30 let end = [start[0] + width, start[1] + length];
31 let borderWidth = 0;
32 let height = params.height;
33 var box = TwoPointRoundedBox({ 34 start: start,
35 end: end,
36 borderWidth: borderWidth,
'TwoPointRoundedLine' was used before it was defined
7 let end = params.end;
8 let width = params.width;
9 let height = params.height;
10 var box = TwoPointRoundedLine({ 11 start: start,
12 end: end,
13 width: width,
'TwoPointRoundedBox' was used before it was defined
49 let end = params.end;
50 let borderWidth = params.borderWidth;
51 let height = params.height;
52 var box = TwoPointRoundedBox({ 53 start: start,
54 end: end,
55 borderWidth: borderWidth,
'TwoPointRoundedLine' was used before it was defined
148 width: borderWidth,
149 height: height
150 });
151 var down = TwoPointRoundedLine({152 start: bottomRight,
153 end: bottomLeft,
154 width: borderWidth,
'TwoPointRoundedLine' was used before it was defined
142 width: borderWidth,
143 height: height
144 });
145 var right = TwoPointRoundedLine({146 start: topRight,
147 end: bottomRight,
148 width: borderWidth,
'TwoPointRoundedLine' was used before it was defined
136 width: borderWidth,
137 height: height
138 });
139 var top = TwoPointRoundedLine({140 start: topLeft,
141 end: topRight,
142 width: borderWidth,
'TwoPointRoundedLine' was used before it was defined
130 var matrix = new THREE.Matrix4();
131 core.applyMatrix(matrix.makeTranslation(w / 2, h / 2, height / 2));
132 core.applyMatrix(matrix.makeTranslation(bottomLeft[0], bottomLeft[1], 0));
133 var left = TwoPointRoundedLine({134 start: bottomLeft,
135 end: topLeft,
136 width: borderWidth,
'renderEdge' was used before it was defined
34 let rendererInfo = renderTextTarget;
35 return rendererInfo;
36 } else if (typeString == "EDGE") {
37 return renderEdge; 38 } else {
39 let rendererInfo = FeatureSets.getRender2D(typeString, setString);
40 return rendererInfo;
'renderTextTarget' was used before it was defined
31
32export function getFeatureRenderer(typeString, setString) {
33 if (typeString == "TEXT") {
34 let rendererInfo = renderTextTarget; 35 return rendererInfo;
36 } else if (typeString == "EDGE") {
37 return renderEdge;
'drawCircle' was used before it was defined
268 } else if (dxfobject.getType() === "ELLIPSE") {
269 path.addChild(drawEllipse(dxfobject.getData()));
270 } else if (dxfobject.getType() === "CIRCLE") {
271 path.addChild(drawCircle(dxfobject.getData()));272 } else {
273 console.error("Unsupported DXF Entity Type for Outline Generation : " + dxfobject.getType());
274 }
'drawEllipse' was used before it was defined
266 } else if (dxfobject.getType() === "SPLINE") {
267 path.addChild(drawSpline(dxfobject.getData()));
268 } else if (dxfobject.getType() === "ELLIPSE") {
269 path.addChild(drawEllipse(dxfobject.getData()));270 } else if (dxfobject.getType() === "CIRCLE") {
271 path.addChild(drawCircle(dxfobject.getData()));
272 } else {
'drawSpline' was used before it was defined
264 } else if (dxfobject.getType() === "LWPOLYLINE" || dxfobject.getType() === "LINE" || dxfobject.getType() === "POLYLINE") {
265 path.addChild(drawLine(dxfobject.getData()));
266 } else if (dxfobject.getType() === "SPLINE") {
267 path.addChild(drawSpline(dxfobject.getData()));268 } else if (dxfobject.getType() === "ELLIPSE") {
269 path.addChild(drawEllipse(dxfobject.getData()));
270 } else if (dxfobject.getType() === "CIRCLE") {
'drawLine' was used before it was defined
262 if (dxfobject.getType() === "ARC") {
263 path.addChild(drawArc(dxfobject.getData()));
264 } else if (dxfobject.getType() === "LWPOLYLINE" || dxfobject.getType() === "LINE" || dxfobject.getType() === "POLYLINE") {
265 path.addChild(drawLine(dxfobject.getData()));266 } else if (dxfobject.getType() === "SPLINE") {
267 path.addChild(drawSpline(dxfobject.getData()));
268 } else if (dxfobject.getType() === "ELLIPSE") {
'drawArc' was used before it was defined
260 // Figure out what entity this is and then based on that do the drawing
261 let mesh;
262 if (dxfobject.getType() === "ARC") {
263 path.addChild(drawArc(dxfobject.getData()));264 } else if (dxfobject.getType() === "LWPOLYLINE" || dxfobject.getType() === "LINE" || dxfobject.getType() === "POLYLINE") {
265 path.addChild(drawLine(dxfobject.getData()));
266 } else if (dxfobject.getType() === "SPLINE") {
'drawCircle' was used before it was defined
202 } else if (dxfobject.getType() === "ELLIPSE") {
203 closedshapes.push(drawEllipse(dxfobject.getData()));
204 } else if (dxfobject.getType() === "CIRCLE") {
205 closedshapes.push(drawCircle(dxfobject.getData()));206 } else if (dxfobject.getType() === "SPLINE") {
207 alert("The current version of the DXF Parser does not support SPLINE objects. Support will be added in future versions");
208 throw new Error("Unsupported render object");
'drawEllipse' was used before it was defined
200 processPolyLine(geometryGraph, dxfobject.getData());
201 }
202 } else if (dxfobject.getType() === "ELLIPSE") {
203 closedshapes.push(drawEllipse(dxfobject.getData()));204 } else if (dxfobject.getType() === "CIRCLE") {
205 closedshapes.push(drawCircle(dxfobject.getData()));
206 } else if (dxfobject.getType() === "SPLINE") {
'renderDXFObjects' was used before it was defined
20 let color = params["color"];
21 let rotation = params["rotation"];
22 let p = new paper.Point(position[0], position[1]);
23 let render = renderDXFObjects(customcomponent.dxfData); 24
25 render.fillColor = color;
26 render.fillColor.alpha = 0.5;
Description
It is recommended to use a variable only after it is defined as it might produce errors at runtime.
In JavaScript, prior to ES6, variable and function declarations are hoisted to the top of a scope, so it's possible to use identifiers before their formal declarations in code. This can be confusing and some believe it is best to always declare variables and functions before using them.
In ES6, block-level bindings (let
and const
) introduce a "temporal dead zone" where a ReferenceError
will be thrown with any attempt to access the variable before its declaration.
Bad Practice
alert(a);
var a = 10;
f();
function f() {}
function g() {
return b;
}
var b = 1;
{
alert(c);
let c = 1;
}
Recommended
var a;
a = 10;
alert(a);
function f() {}
f(1);
var b = 1;
function g() {
return b;
}
{
let c;
c++;
}