- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 448 Articles for Programming Scripts
93 Views
Use the throw statement to raise your built-in exceptions or your customized exceptions. Later these exceptions can be captured and you can take appropriate action.ExampleYou can try to run the following code to implement throw statement − Click the following to see the result:
1K+ Views
setTimeout() function setTimeout( function, duration) − This function calls function after duration milliseconds from now. This goes for one execution. Let’s see an example − It waits for 2000 milliseconds, and then runs the callback function alert(‘Hello’) − setTimeout(function() { alert('Hello');}, 2000); setInterval() function setInterval(function, duration) − This function calls function after every duration milliseconds. This goes for unlimited times. Let’s see an example − It triggers the alert(‘Hello’) after every 2000 milliseconds, not only once. setInterval(function() { alert('Hello');}, 2000);
96 Views
can use several Navigator related properties in your Web page. The following are the properties −Sr.NoProperty & Description1appCodeNameThis property is a string that contains the code name of the browser, Netscape for Netscape and Microsoft Internet Explorer for Internet Explorer.2appVersionThis property is a string that contains the version of the browser as well as other useful information such as its language and compatibility.3languageThis property contains the two-letter abbreviation for the language that is used by the browser. Netscape only.4mimTypes[]This property is an array that contains all MIME types supported by the client. Netscape only.5platform[]This property is a string that contains ... Read More
101 Views
To add debugging code to JavaScript, use the alert() or document.write() methods in your program. For example,var debugging = true; var whichImage = "widget"; if( debugging ) alert( "Calls swapImage() with argument: " + whichImage ); var swapStatus = swapImage( whichImage ); if( debugging ) alert( "Exits swapImage() with swapStatus=" + swapStatus );Examine the content and order of the alert() as they appear, you can examine the health of your program very easily.
122 Views
To reduce the number of errors in scripts, follow the below-given tips −Use plenty of comments. Comments enable you to explain why you wrote the script the way you did and to explain particularly difficult sections of code.Always use indentation to make your code easy to read. Indenting statements also make it easier for you to match up the beginning and ending tags, curly braces, and other HTML and script elements.Write modular code. Whenever possible, group your statements into functions. Functions let you group related statements, and test and reuse portions of code with minimal effort.Be consistent in the way you ... Read More
251 Views
The #define directive is a preprocessor directive; the preprocessor replaces those macros by their body before the compiler even sees it. Think of it as an automatic search and replace of your source code.A const variable declaration declares an actual variable in the language, which you can use like a real variable: take its address, pass it around, cast it, convert it, etc.Without compiler optimizations, there is a hidden cost of memory allocation associated with both of these in different cases. But with proper optimizations they are more or less the same. Also, preprocessor macros don't have any scope, while ... Read More
5K+ Views
You can subtract a day from a Python date using the timedelta object. You need to create a timedelta object with the amount of time you want to subtract. Then subtract it from the date. Example from datetime import datetime from datetime import timedelta today = datetime.today() yesterday = today - timedelta(days=1) print(today) print() print(yesterday)OutputThis will give the output −2017-12-29 12:28:06.531791 2017-12-28 12:28:06.531791You can also subtract years, months, hours, etc. in the same way from a date using the timedelta object.