Skip to content

Instantly share code, notes, and snippets.

View manojsinghnegiwd's full-sized avatar
🎯
Focusing

Manoj Singh Negi manojsinghnegiwd

🎯
Focusing
View GitHub Profile
@manojsinghnegiwd
manojsinghnegiwd / merge.js
Created October 19, 2016 18:32
Function to merge object in javascript and return a new merged object
var merge = function() {
var object = {};
for( var i = 0; i < arguments.length; i++ ) {
for(var prop in arguments[i]) {
object[prop] = arguments[i][prop];
}
}
return object;
}
var x = (function IIFE(){
return 'Hello I am IIFE';
})();
console.log(x) // will log Hello I am IIFE
var arr = [
"1",
"2",
"3",
"4",
"5"
];
var str = arr.join(",");
@manojsinghnegiwd
manojsinghnegiwd / Concat.js
Last active November 17, 2016 21:09
Working with arrays in javascript Part 2
var arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100];
var arrCopy = [110, 120, 130, 140, 150, 160, 170, 180, 190, 200];
var newArr = arr.concat(arrCopy);
console.log(newArr);
console.log(arr);
console.log(arrCopy);
// output
// [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]
// [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]
@manojsinghnegiwd
manojsinghnegiwd / getFirstElem.js
Last active February 23, 2017 08:13
Get first element of an object
function getFirst (obj) {
var first = null;
for(var prop in obj) {
first = obj[prop];
break;
}
return first;
}
var obj = {
@manojsinghnegiwd
manojsinghnegiwd / Button.jsx
Created March 11, 2017 17:42
Creating A React Native Android Button Component.
export default class Button extends Component {
render () {
let {onPress, isRipple, rippleColor, children, style} = this.props;
return (
<View>
<TouchableNativeFeedback
onPress={onPress}
background={isRipple ? TouchableNativeFeedback.Ripple(rippleColor || "#000000") : null}>
<View style={style}>
{children}
<TextInput
placeholder="Your Placeholder"
onChangeText={(value) => this.setState({value})}
style={[newStyle]}
editable={true}
multiline={true}
value={value}
onContentSizeChange={(e) => this.updateSize(e.nativeEvent.contentSize.height)}
/>
import {
TextInput
} from 'react-native';
this.state = {
value: '',
height: 40
}
const {value, height} = this.state;