Deep and Shallow Copy in JavaScript

Deep copy duplicates both values and memory addresses, creating a new independent object. Shallow copy only copies the reference address, sharing memory with the original object, so changes to the original affect the copy.

For shallow copies:

  • Direct assignment (=)
  • Spread operator (...)
  • Object.assign()

For deep copies:

  • JSON.stringify() followed by JSON.parse()
  • Object.create()

Note: Object.assign() performs deep copy for primitive values but shallow copy for object references.

Semantic HTML tags improve code readability by clearly indicating content structure.

ES6 introduced key features:

  • let and const for block-scoped variables
  • Destructuring assignment
  • Template literals for string interpolation
  • Spread operator for array/object manipulation
  • Arrow functions
  • Classes
  • Promises for asynchronous operations
  • Set and Map collections
  • Symbol for unique property keys

Event bubbling propagates events from child to parent elements. Cancel with:

element.onclick = function(event) {
    event = event || window.event;
    event.cancelBubble = true;
}

CSS box model:

  • Padding: space between element content and border
  • Margin: space between elements

Vue conditional rendering:

  • v-if: Toggles DOM element existence
  • v-show: Toggles CSS display property

CSS units:

  • px: Fixed pixels
  • em: Relative to parent font-size
  • rem: Relative to root element font-size
  • vw/vh: Viewport width/height percentages

Webpack configuration example:

const path = require('path');

module.exports = {
    entry: './src/main.js',
    output: {
        path: path.resolve(__dirname, 'dist'),
        filename: 'bundle.js'
    },
    module: {
        rules: [
            { test: /\.vue$/, use: 'vue-loader' }
        ]
    },
    plugins: []
};

JavaScript event loop processes synchronous tasks first, then asynchronous tasks from microtask and macrotask queues.

Vue Router implements client-side routing using hash mode or HTML5 History API.

CSS selector specificity (highest to lowest):

  1. Inline styles
  2. ID selectors
  3. Class/pseudo-class selectors
  4. Element/pseudo-element selectors

Flexbox layout properties: Container:

  • justify-content: Horizontal alignment
  • align-items: Vertical alignment
  • flex-direction: Main axis direction
  • flex-wrap: Wrapping behavior

Items:

  • order: Display order
  • flex-grow: Growth factor
  • flex-shrink: Shrink factor
  • flex-basis: Initial size

Cookies store session data in browsers, primarily for authentication.

Vue lifecycle hooks:

  • created: After instance creation, before DOM mounting
  • mounted: After DOM is mounted created executes before mounted.

Web storage:

  • localStorage: Persistent storage
  • sessionStorage: Session-only storage
  • Cookies: Small data with expiration

HTTP status codes:

  • 2xx: Success
  • 3xx: Redirection
  • 4xx: Client errors
  • 5xx: Server errors

Array deduplication methods:

  • Set constructor
  • Array.prototype.indexOf()
  • Array.prototype.includes()

Mobile responsive techniques:

  • Viewport meta tag
  • Media queries
  • Flexible units (vw, vh, rem, %)

Position elements at bottom:

  • Absolute/fixed positioning with bottom: 0
  • Previous element with 100vh height

JavaScript prototype chain enables inheritance through prototype objects.

Routers operate at the network layer in OSI model.

Bubble sort time complexity: O(n²)

Virtual DOM optimizes updates by comparing JavaScript object representations before applying minimal DOM changes.

Vue component data must be a function to prevent shared state across instances.

DOM selection:

  • querySelector(): First matching element
  • querySelectorAll(): NodeList of all matches

Function parameter passing:

  • Primitives: By value
  • Objects: By reference

Array type checking:

  • Array.isArray()
  • instanceof Array

CSS triangle:

.triangle {
    width: 0;
    height: 0;
    border-left: 50px solid transparent;
    border-right: 50px solid transparent;
    border-bottom: 100px solid #000;
}

Text alignment:

  • Single line: text-align: center
  • Multiple lines: text-align: left

Element hiding:

  • display: none: Removes from layout
  • visibility: hidden: Hides but preserves space

Array iteration:

  • forEach(): Executes callback, returns undefined
  • map(): Returns new transformed array

Vue template abbreviations:

  • v-on: @
  • v-bind: :
  • v-slot: #

Tags: javascript Vue.js css web development frontend

Posted on Sat, 29 Aug 2026 16:54:42 +0000 by nafetski