#2 Perbedaan inline, internal dan external javascript

Belajar Coding
16 Oct 202111:35

Summary

TLDRIn this video, the presenter explores three methods for writing JavaScript: Inline, Internal, and External. Inline JavaScript is placed directly within HTML tags, suitable for single-page applications. Internal JavaScript is written within `<script>` tags in the same HTML file, also limited to one page. External JavaScript, on the other hand, is stored in separate `.js` files and can be utilized across multiple HTML pages, enhancing reusability. The video emphasizes the importance of choosing the right method based on project size and complexity, making it a valuable resource for those learning JavaScript.

Takeaways

  • ๐Ÿ˜€ Inline JavaScript is written directly within HTML tags, making it applicable only to a single webpage.
  • ๐Ÿ˜€ Internal JavaScript is placed within a `<script>` tag in the HTML document and is also limited to that specific page.
  • ๐Ÿ˜€ External JavaScript is stored in a separate file with a `.js` extension, allowing it to be reused across multiple webpages.
  • ๐Ÿ˜€ Each method of writing JavaScript is similar to writing CSS, which can also be inline, internal, or external.
  • ๐Ÿ˜€ Inline JavaScript allows for quick scripts but can lead to cluttered HTML code.
  • ๐Ÿ˜€ Internal JavaScript keeps scripts within the HTML file but can make the file large and harder to manage.
  • ๐Ÿ˜€ External JavaScript enhances maintainability and organization, especially in larger projects.
  • ๐Ÿ˜€ Itโ€™s important to ensure the correct file path when linking external JavaScript to avoid errors.
  • ๐Ÿ˜€ The document demonstrates basic JavaScript functionality, such as creating alerts through button clicks.
  • ๐Ÿ˜€ Best practices suggest using external JavaScript for large projects to maintain clean and organized code.

Q & A

  • What are the three methods of writing JavaScript discussed in the video?

    -The three methods discussed are Inline, Internal, and External JavaScript.

  • How does Inline JavaScript differ from Internal and External methods?

    -Inline JavaScript is written directly within an HTML tag and can only be used on one webpage, while Internal JavaScript is placed within a `<script>` element in the HTML file and also limited to one page. External JavaScript is written in a separate file and can be used across multiple webpages.

  • Can you give an example of how Inline JavaScript is used?

    -Inline JavaScript can be used to add a function directly to a button tag, such as displaying a pop-up when the button is clicked.

  • What is the purpose of using Internal JavaScript?

    -Internal JavaScript is used for organizing JavaScript code within a specific HTML document, allowing for clearer structure and easier management of scripts related to that page.

  • What are the steps to create an External JavaScript file?

    -To create an External JavaScript file, you need to write your JavaScript code in a separate file with a `.js` extension and then link this file to your HTML using the `<script>` tag.

  • What are the potential errors that could arise when linking to an External JavaScript file?

    -Common errors include incorrect file paths or file names, which can result in 'file not found' errors when the browser attempts to access the JavaScript file.

  • Why is it beneficial to use External JavaScript for larger projects?

    -Using External JavaScript allows for better organization of code, reusability across multiple HTML pages, and improved maintainability of the project.

  • What is the importance of semicolons in JavaScript code?

    -Semicolons are important in JavaScript to indicate the end of a statement; forgetting to include them can lead to errors or unexpected behavior in the code.

  • How can you troubleshoot issues with JavaScript in a webpage?

    -You can troubleshoot JavaScript issues by using browser developer tools to inspect the console for error messages, which can help identify problems with the code or file paths.

  • What did the presenter suggest doing if viewers found the video helpful?

    -The presenter encouraged viewers to like the video and subscribe to the channel for more helpful content.

Outlines

plate

This section is available to paid users only. Please upgrade to access this part.

Upgrade Now

Mindmap

plate

This section is available to paid users only. Please upgrade to access this part.

Upgrade Now

Keywords

plate

This section is available to paid users only. Please upgrade to access this part.

Upgrade Now

Highlights

plate

This section is available to paid users only. Please upgrade to access this part.

Upgrade Now

Transcripts

plate

This section is available to paid users only. Please upgrade to access this part.

Upgrade Now
Rate This
โ˜…
โ˜…
โ˜…
โ˜…
โ˜…

5.0 / 5 (0 votes)

Related Tags
JavaScript BasicsWeb DevelopmentCoding TechniquesInline ScriptInternal ScriptExternal ScriptProgramming TipsHTML IntegrationScript FunctionsLearning Resources