This question already has answers here:
Break on a change of variable value
(3 answers)
Closed 6 years ago.
I've got two variables pointing at the same object. At some time one of the variable changes its reference to another object.
Are there any debugging tools or techniques to find out place where the link breaks?
You can set a breakpoint in your Chrome developer tools under the Sources tab. When this code is reached, you can see the current scope and all its variables/values on the right hand side under the Scope panel. Then just navigate through the functions using the controls above it and see when the values change.
Related
This question already has an answer here:
How could I check the meaning of Vscode's popup-menu icon stands for?
(1 answer)
Closed 12 months ago.
How can i find these icons meanings? And also there are same codes but different icons there (2x LN10) why?
You can find them on the IntelliSense section of the VSCode docs. They typically refer to the types of the variable or value that they are referencing and can be modified by extensions as well. You can read more about them here: https://code.visualstudio.com/docs/editor/intellisense#_types-of-completions
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 1 year ago.
Improve this question
remember, I am a beginner. So I have been using the alert(variable_here)
function to check and make sure any variables I a changing are doing what they are supposed to while I am coding. For example:
var randomevariable = (2)//set the variable
randomvariable = (randomvariable + 1)
alert(randomvariable)//see how I used the alert function as temporary statement for checking the variable?
Is there a better way to view a variable than document.write and alert?
I would recommend using console.log or the debugger statement:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/debugger
https://developer.mozilla.org/en-US/docs/Web/API/Console/log
Debugging using a modern browser also helps:
https://developer.chrome.com/docs/devtools/open/
You can use the web browser's console, typically accessible with Right click > Inspect.
To print anything in the console while the code is running, you can put this in Javascript:
console.log(randomvariable)
This is less disruptive than alert!
If you're working in a browser environment, console.log() is going to give you an easier time than using alert() - using Chrome and most other modern browsers, you can press CTRL+Shift+I to open Chrome Dev Tools to see the chrome console and see the output of console.log() there.
There are some cases when debugging more complex bugs I also like to put variables on the window object - this gives them a global scope and lets me check their value at any given moment.
For example: window.myVar = myVar;
Then, later, when I want to check the value while debugging, you can go into the same chrome dev tools and type window.myVar to see their value.
This question already has answers here:
Get current clipboard content? [closed]
(4 answers)
Closed 5 years ago.
Is there a way in Angular2 to get text from the clipboard? I found a lot of information about copying to the clipboard, but nothing regarding the other way around.
you can use this, but this is in a javascript way, you may need to modify this in typescript with event binding on which you want to show.
window.clipboardData.getData('Text')
but it will work in some browsers. However, many browsers where it does work will prompt the user as to whether or not they wish the web page to have access to the clipboard.
This question already has answers here:
Do DOM tree elements with IDs become global properties?
(5 answers)
What is the difference between getElementById and simply using an element's ID as a variable?
(2 answers)
Closed 5 years ago.
So, I was coding in class when accidentally got to this point, when you set any ID in HTML5 a global variable is created at the same time, which can be used on the script aparently the same way we use getElementById().
for example:
<div id="identifier"></div>
can be accessed in the script like:
identifier.style.whatever
Can anyone explain me why I can't find any information about this? also, why isn't anyone using this when coding? is it bad to use this instead of getElementById?
This question already has answers here:
Making a window pop under in chrome
(8 answers)
Closed 7 years ago.
I want to open a pop-under window on click, but I want to open it behind the current window.
I google this and found nothing useful about my problem.
Is there a way to do it?
Perhaps a simple path setting is what you need. Use this within a javascript sequence:
path = window.document.URL;
window.open(path,"_self");