Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

js console log with color

console.log('%c Oh my heavens! ', 'background: #222; color: #bada55');
Comment

js colored console log

/**
 * @param {string} text text to return
 * @param {string} color enums: [black, red, green, yellow, blue, magenta, cyan, white]
 * @returns colored text
 */
const colorConsoleText = (text, color = 'black') => {
    const colors = {
        black: "x1b[30m",
        red: "x1b[31m",
        green: "x1b[32m",
        yellow: "x1b[33m",
        blue: "x1b[34m",
        magenta: "x1b[35m",
        cyan: "x1b[36m",
        white: "x1b[37m",
        console_color: 'x1b[0m'
    }
    const coloredText = `${colors[color]}${text}${colors.console_color}`
    return coloredText
}
Comment

js console.log color

console.log('%c My txt ', 'My css');

// Example
console.log('%c Hello world ', 'background: #222; color: #bada55');
Comment

javascript colorized console.log

console.log('%cconsole.log', 'color: green;');
console.info('%cconsole.info', 'color: green;');
console.debug('%cconsole.debug', 'color: green;');
console.warn('%cconsole.warn', 'color: green;');
console.error('%cconsole.error', 'color: green;');
Comment

how to change the color of a console.log in javascript

// Download the npm package "colors"
// npm i colors

var colors = require("colors");

console.log("Hello World".blue);

// output: Hello World (Its blue btw lmao)
Comment

javascript colorized console.log

const styles = ['color: green', 'background: yellow'].join(';');

const message = 'Some Important Message Here';

// 3. Using the styles and message variable
console.log('%c%s', styles, message);
Comment

javascript console.log colors

console.log('x1b[33m%sx1b[0m', 'hi!')
Comment

javascript colorized console.log

console.log(
  'Nothing here %cHi Cat %cHey Bear', // Console Message
  'color: blue',
  'color: red', // CSS Style
);
Comment

javascript console.log colors

console.log('%c Hello World','color:red;border:1px solid dodgerblue');
Comment

javascript colorized console.log

// 1. Pass the css styles in an array
const styles = [
  'color: green',
  'background: yellow',
  'font-size: 30px',
  'border: 1px solid red',
  'text-shadow: 2px 2px black',
  'padding: 10px',
].join(';'); // 2. Concatenate the individual array item and concatenate them into a string separated by a semi-colon (;)

// 3. Pass the styles variable
console.log('%cHello There', styles);
Comment

PREVIOUS NEXT
Code Example
Javascript :: how to disable right click in javascript 
Javascript :: how to hack the chrome dinosaur game 
Javascript :: how to check nan in jquery 
Javascript :: export type you may need an appropriate loader to handle this file type 
Javascript :: webview javascript enabled 
Javascript :: regex space javascript 
Javascript :: TypeError: date.getHours is not a function 
Javascript :: react native textinput turnoff capitalize first letter 
Javascript :: autherization token in axios 
Javascript :: check textbox is empty in jquery 
Javascript :: javascript convert number from thousands to k and millions to m 
Javascript :: load json 
Javascript :: npm ERR! peer dep missing: @babel/core@^7.13.0, required by @babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining@7.14.5 
Javascript :: como deletar node js linux 
Javascript :: get unique values from array of objects javascript 
Javascript :: useeffect umnount 
Javascript :: search in a table jquery 
Javascript :: mysql innodb_buffer_pool_size 
Javascript :: node list files in directory 
Javascript :: electron specify minimum size 
Javascript :: Handlebars: Access has been denied to resolve the property 
Javascript :: js document ready 
Javascript :: react split array into chunks 
Javascript :: node read csv 
Javascript :: js escape url parameter 
Javascript :: min object value in array 
Javascript :: react native linking phone call 
Javascript :: max value in array javascript 
Javascript :: javascript reverse array map 
Javascript :: scrollview child layout ( justifycontent ) must be applied through the contentcontainerstyle prop 
ADD CONTENT
Topic
Content
Source link
Name
6+6 =